import { defaHttp, Api } from "../index";
import { funDelay } from "@@/utils/tools/function";

/**获取活体检测用的sessionId */
export async function apiGetSessionId(
  count = 1
): Promise<void | ApiGetSessionId.Data> {
  const res = await defaHttp.post<Api.Res<ApiGetSessionId.Data>>(
    "/user/get/session_id"
  );
  count++;
  if (count > 10) return res.data;
  if (res.code !== 200) return funDelay(apiGetSessionId, [count]);
  return res.data;
}
/**获取活体检测用的sessionId */
export namespace ApiGetSessionId {
  export interface Data {
    /**session_id */
    session_id: string;
  }
}

/**获取活体检测结果 */
export async function apiGetBioassay(
  data: ApiGetBioassay.Req
): Promise<Api.Res<void>> {
  const res = await defaHttp.post<Api.Res<void>>(
    "/user/get/session/result",
    data
  );
  return res;
}
/**获取活体检测结果 */
export namespace ApiGetBioassay {
  export interface Req {
    /**session_id */
    session_id: string;
  }
}
